<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="nginx," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="前言在上一篇中介绍了Nginx的安装，本篇文章主要介绍的是Nginx如何实现负载均衡。 负载均衡介绍介绍在介绍Nginx的负载均衡实现之前，先简单的说下负载均衡的分类，主要分为硬件负载均衡和软件负载均衡，硬件负载均衡是使用专门的软件和硬件相结合的设备，设备商会提供完整成熟的解决方案，比如F5，在数据的稳定性以及安全性来说非常可靠，但是相比软件而言造价会更加昂贵；软件的负载均衡以Nginx这类软件">
<meta name="keywords" content="nginx">
<meta property="og:type" content="article">
<meta property="og:title" content="Nginx+SpringBoot实现负载均衡">
<meta property="og:url" content="http://yoursite.com/2019/11/28/pancm125/index.html">
<meta property="og:site_name" content="虚无境的博客">
<meta property="og:description" content="前言在上一篇中介绍了Nginx的安装，本篇文章主要介绍的是Nginx如何实现负载均衡。 负载均衡介绍介绍在介绍Nginx的负载均衡实现之前，先简单的说下负载均衡的分类，主要分为硬件负载均衡和软件负载均衡，硬件负载均衡是使用专门的软件和硬件相结合的设备，设备商会提供完整成熟的解决方案，比如F5，在数据的稳定性以及安全性来说非常可靠，但是相比软件而言造价会更加昂贵；软件的负载均衡以Nginx这类软件">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20191128191516195.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly94dXd1amluZy5ibG9nLmNzZG4ubmV0,size_16,color_FFFFFF,t_70">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20191128203846208.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly94dXd1amluZy5ibG9nLmNzZG4ubmV0,size_16,color_FFFFFF,t_70">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20191128204203424.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly94dXd1amluZy5ibG9nLmNzZG4ubmV0,size_16,color_FFFFFF,t_70">
<meta property="og:updated_time" content="2019-12-08T11:43:22.937Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Nginx+SpringBoot实现负载均衡">
<meta name="twitter:description" content="前言在上一篇中介绍了Nginx的安装，本篇文章主要介绍的是Nginx如何实现负载均衡。 负载均衡介绍介绍在介绍Nginx的负载均衡实现之前，先简单的说下负载均衡的分类，主要分为硬件负载均衡和软件负载均衡，硬件负载均衡是使用专门的软件和硬件相结合的设备，设备商会提供完整成熟的解决方案，比如F5，在数据的稳定性以及安全性来说非常可靠，但是相比软件而言造价会更加昂贵；软件的负载均衡以Nginx这类软件">
<meta name="twitter:image" content="https://img-blog.csdnimg.cn/20191128191516195.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly94dXd1amluZy5ibG9nLmNzZG4ubmV0,size_16,color_FFFFFF,t_70">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2019/11/28/pancm125/"/>






  <title>Nginx+SpringBoot实现负载均衡 | 虚无境的博客</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?39c177d10f6e05ddfa113e02139b9c1c";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">虚无境的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/11/28/pancm125/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="虚无境">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/xuwujing.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="虚无境的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Nginx+SpringBoot实现负载均衡</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-11-28T00:00:00+08:00">
                2019-11-28
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/nginx/" itemprop="url" rel="index">
                    <span itemprop="name">nginx</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <script src="\assets\js\APlayer.min.js"> </script><h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>在上一篇中介绍了<a href="https://www.cnblogs.com/xuwujing/p/11899890.html" target="_blank" rel="external">Nginx的安装</a>，本篇文章主要介绍的是Nginx如何实现负载均衡。</p>
<h2 id="负载均衡介绍"><a href="#负载均衡介绍" class="headerlink" title="负载均衡介绍"></a>负载均衡介绍</h2><h3 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h3><p>在介绍Nginx的负载均衡实现之前，先简单的说下负载均衡的分类，主要分为<strong>硬件负载均衡和软件负载均衡</strong>，硬件负载均衡是使用专门的软件和硬件相结合的设备，设备商会提供完整成熟的解决方案，比如F5，在数据的稳定性以及安全性来说非常可靠，但是相比软件而言造价会更加昂贵；软件的负载均衡以Nginx这类软件为主，实现的一种消息队列分发机制。</p>
<p>简单来说所谓的负载均衡就是把很多请求进行分流，将他们分配到不同的服务器去处理。比如我有3个服务器，分别为A、B、C，然后使用Nginx进行负载均衡，使用轮询策略，此时如果收到了9个请求，那么会均匀的将这9个请求分发给A、B、Cf服务器，每一个服务器处理3个请求，这样的话我们可以利用多台机器集群的特性减少单个服务器的压力。</p>
<p>Nginx实现负载均衡的示例图:</p>
<p><img src="https://img-blog.csdnimg.cn/20191128191516195.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly94dXd1amluZy5ibG9nLmNzZG4ubmV0,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<h3 id="负载均衡策略"><a href="#负载均衡策略" class="headerlink" title="负载均衡策略"></a>负载均衡策略</h3><p>NGINX开源支持四种负载平衡方法，而NGINX Plus又增加了两种方法。</p>
<p>1.Round Robin: 对所有的请求进行轮询发送请求，默认的分配方式。</p>
<p>nginx.conf 配置示例:</p>
<pre><code>upstream xuwujing {
   server www.panchengming.com;
   server www.panchengming2.com;
}
</code></pre><p><strong>注:上面的域名也可以用IP替代。</strong></p>
<p>2.Least Connections： 以最少的活动连接数将请求发送到服务器，同样要考虑服务器权重。</p>
<p>nginx.conf 配置示例:</p>
<pre><code>upstream xuwujing {
    least_conn;
    server www.panchengming.com;
    server www.panchengming2.com;
}
</code></pre><p>3.IP Hash : 发送请求的服务器由客户机IP地址决定。在这种情况下，使用IPv4地址的前三个字节或整个IPv6地址来计算散列值。该方法保证来自相同地址的请求到达相同的服务器，除非该服务器不可用。</p>
<pre><code>upstream xuwujing {
     ip_hash;
     server www.panchengming.com;
     server www.panchengming2.com;
}
</code></pre><p>4.Generic Hash: 请求发送到的服务器由用户定义的键决定，该键可以是文本字符串、变量或组合。 </p>
<pre><code>upstream xuwujing {
    hash $request_uri consistent;
    server www.panchengming.com;
    server www.panchengming2.com;
}
</code></pre><p>5.Least Time (NGINX Plus only) – 对于每个请求，NGINX Plus选择具有最低平均延迟和最低活动连接数的服务器，其中最低平均延迟是根据包含least_time指令的下列参数计算的:</p>
<ul>
<li>header ： 从服务器接收第一个字节的时间。</li>
<li>last_byte： 从服务器接收完整响应的时间。</li>
<li>last_byte inflight：从服务器接收完整响应的时间。</li>
</ul>
<pre><code>upstream xuwujing {
    least_time header;
    server www.panchengming.com;
    server www.panchengming2.com;
}
</code></pre><p>6.Random：每个请求将被传递到随机选择的服务器。如果指定了两个参数，首先，NGINX根据服务器权重随机选择两个服务器，然后使用指定的方法选择其中一个。</p>
<ul>
<li>least_conn ：活动连接的最少数量</li>
<li>least_time=header (NGINX Plus)：从服务器接收响应标头的最短平均时间 ($upstream_header_time)。</li>
<li>least_time=last_byte (NGINX Plus) ：从服务器接收完整响应的最短平均时间（$upstream_response_time）。</li>
</ul>
<pre><code>upstream xuwujing {
         random two least_time=last_byte;
        server www.panchengming.com;
        server www.panchengming2.com;
    }
</code></pre><h2 id="Nginx-SpringBoot实现负载均衡"><a href="#Nginx-SpringBoot实现负载均衡" class="headerlink" title="Nginx+SpringBoot实现负载均衡"></a>Nginx+SpringBoot实现负载均衡</h2><h3 id="环境准备"><a href="#环境准备" class="headerlink" title="环境准备"></a>环境准备</h3><ul>
<li>依赖JDK1.8以上的版本；</li>
<li>依赖<a href="https://www.cnblogs.com/xuwujing/p/11899890.html" target="_blank" rel="external">Nginx环境</a>；</li>
</ul>
<p>这里的项目就用本人之前的一个springboot项目，<a href="https://github.com/xuwujing/springBoot-study/tree/master/springboot-thymeleaf" target="_blank" rel="external">SpringBoot的项目地址</a>: <a href="https://github.com/xuwujing/springBoot-study/tree/master/springboot-thymeleaf" target="_blank" rel="external">https://github.com/xuwujing/springBoot-study/tree/master/springboot-thymeleaf</a></p>
<p>首先我们下载这个项目，输入:<code>mvn clean package</code> 将项目进行打包为jar文件,然后将<code>application.properties</code>和此jar项目放在一个文件夹中，然后复制该文件夹(这里为了清晰所以进行复制，实际不复制更改端口重启也行)，修改复制文件夹<code>application.properties</code>的端口，比如改为8086。</p>
<h3 id="Nginx-配置"><a href="#Nginx-配置" class="headerlink" title="Nginx 配置"></a>Nginx 配置</h3><p>我们找到nginx的配置文件nginx.conf，该配置在<strong>nginx/conf/nginx.conf</strong>目录下，然后我们来修改该配置，新增如下配置:</p>
<pre><code>upstream pancm{
   server 127.0.0.1:8085;
   server 127.0.0.1:8086;
}
</code></pre><ul>
<li>upstream pancm：定义一个名称，随意就行；</li>
<li>server + ip:端口 or 域名；</li>
</ul>
<p>如果不想使用Round Robin策略，也可以换成其他的。</p>
<p>然后在server添加/修改如下配置:</p>
<pre><code>server {
       listen       80;
       server_name  127.0.0.1;


       location / {
           root   html;
           proxy_pass http://pancm;
           proxy_connect_timeout 3s;
           proxy_read_timeout 5s;
           proxy_send_timeout 3s;    
           index  index.html index.htm;
       }

       error_page   500 502 503 504  /50x.html;
       location = /50x.html {
           root   html;
       }
   }
</code></pre><p>配置说明:</p>
<ul>
<li>server: 虚拟主机的名称，一个http中可以配置多个server；</li>
<li>listen：Nginx默认的端口；</li>
<li>server_name：Nginx服务的地址，可以使用域名，多个用空格分隔。</li>
<li>proxy_pass：代理路径，一般配置upstream后面的名称用于实现负载均衡，可以直接配置ip进行跳转；</li>
</ul>
<p><strong>nginx.conf 完整的配置:</strong></p>
<pre><code>events {
    worker_connections  1024;
}

error_log nginx-error.log info;
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

      upstream pancm{
       server 127.0.0.1:8085;
       server 127.0.0.1:8086;
    }

    server {
        listen       80;
        server_name  127.0.0.1;


        location / {
            root   html;
            proxy_pass http://pancm;
            proxy_connect_timeout 3s;
            proxy_read_timeout 5s;
            proxy_send_timeout 3s;    
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
</code></pre><h3 id="负载均衡测试"><a href="#负载均衡测试" class="headerlink" title="负载均衡测试"></a>负载均衡测试</h3><p>在完成Nginx配置之后，我们启动Nginx。<br><strong>linux</strong>输入<code>/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf</code>，如果已经启动可以使用<code>/usr/local/nginx/sbin/nginx -s reload</code>命令进行热加载配置文件，<strong>Windows</strong>直接点击Nginx目录下的<code>nginx.exe</code>或者 <code>cmd</code>运行<code>start nginx</code>进行启动，如果启动了依旧可以使用<code>nginx -s reload</code>进行热加载。</p>
<p>Nginx启动完成之后，我们依次启动刚刚下载的springboot和复制更改端口的项目，输入:<code>java -jar springboot-jsp-thymeleaf.jar</code>启动。</p>
<p>都启动成功之后，我们在浏览器输入服务的ip即可进行访问。</p>
<p>示例图:<br><img src="https://img-blog.csdnimg.cn/20191128203846208.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly94dXd1amluZy5ibG9nLmNzZG4ubmV0,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p><strong>注:这里我使用的是windows系统做测试，实际linux也是一样的。</strong></p>
<p>然后我们进行操作，并查看控制台日志！</p>
<p><img src="https://img-blog.csdnimg.cn/20191128204203424.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly94dXd1amluZy5ibG9nLmNzZG4ubmV0,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>从上述示例图中我们进行4次界面刷新请求，最终平均分配到两个服务中去了，从上述的测试结果中我们实现了负载均衡。</p>
<p>这里我在说一下使用Nginx的注意事项，在进行学习和测试的时候，使用nginx默认的端口实现负载均衡一般没有什么问题，但是当我们在项目中使用的时候，特别有登录界面的并且端口不是80的时候，会出现登录的界面无法跳转，进行调试的话会出现 <strong>net::ERR_NAME_NOT_RESOLVED</strong>这样的错误，出现这个原因的是因为nginx默认的端口是80，那么默认跳转的也是这个，所以出现这种情况的时候，需要在location 下添加proxy_set_header Host  $host:port 这个配置，port 和listen 的端口保持一致就可以了。</p>
<h2 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h2><h3 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h3><p><a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/" target="_blank" rel="external">https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/</a><br><a href="http://nginx.org/en/" target="_blank" rel="external">http://nginx.org/en/</a></p>
<h3 id="相关文章"><a href="#相关文章" class="headerlink" title="相关文章"></a>相关文章</h3><p><a href="https://www.cnblogs.com/xuwujing/p/11899890.html" target="_blank" rel="external">Nginx Linux和Windows安装教程</a>：<a href="https://www.cnblogs.com/xuwujing/p/11899890.html" target="_blank" rel="external">https://www.cnblogs.com/xuwujing/p/11899890.html</a><br><a href="https://www.cnblogs.com/xuwujing/p/10273989.html" target="_blank" rel="external">SpringBoot+SpringCloud实现负载均衡</a>: <a href="https://www.cnblogs.com/xuwujing/p/10273989.html" target="_blank" rel="external">https://www.cnblogs.com/xuwujing/p/10273989.html</a></p>
<h3 id="音乐推荐"><a href="#音乐推荐" class="headerlink" title="音乐推荐"></a>音乐推荐</h3><iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="330" height="86" src="//music.163.com/outchain/player?type=2&id=30474763&auto=0&height=66"></iframe>


<p>原创不易，如果感觉不错，希望点赞或推荐！您的支持是我写作的最大动力！<br>版权声明:<br>作者：虚无境<br>博客园出处：<a href="http://www.cnblogs.com/xuwujing" target="_blank" rel="external">http://www.cnblogs.com/xuwujing</a><br>CSDN出处：<a href="http://blog.csdn.net/qazwsxpcm" target="_blank" rel="external">http://blog.csdn.net/qazwsxpcm</a>　<br>掘金出处：<a href="https://juejin.im/user/5ae45d5bf265da0b8a6761e4" target="_blank" rel="external">https://juejin.im/user/5ae45d5bf265da0b8a6761e4</a>　　　<br>个人博客出处：<a href="http://www.panchengming.com" target="_blank" rel="external">http://www.panchengming.com</a> </p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>
     
    <div>
	 +
	  
<div style="text-align:center;color: #ccc;font-size:14px;">
------ 本文结束 ------</div>
<br/>
<div style="border: 1px solid black">
<div style="margin-left:10px">
<span style="font-weight:blod">版权声明</span>
<!-- <img src="/images/xuwujing.png" > -->
<br/>
<p style="font-size: 10px;line-height: 30px"><a href="http://www.panchengming.com/" style="color:#258FC6">xuwujing's Notes</a> by <a href="http://www.panchengming.com/" style="color:#258FC6">ChengMing Pan</a> is licensed under a <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" style="color:#258FC6">Creative Commons BY-NC-ND 4.0 International License</a>.<br/>
由<a href="http://www.panchengming.com/" style="color:#258FC6">虚无境</a>创作并维护的<a href="http://www.panchengming.com/" style="color:#258FC6">xuwujing's Notes</a>博客采用<a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" style="color:#258FC6">创作共用保留署名-非商业-禁止演绎4.0国际许可证</a>。<br/>
本文首发于<a href="http://www.panchengming.com/" style="color:#258FC6">xuwujing's Notes</a> 博客（ <a href="http://www.panchengming.com/" style="color:#258FC6">http://www.panchengming.com/</a> ），版权所有，侵权必究。</p>
</div>
</div>

	
	</div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/nginx/" rel="tag"># nginx</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/11/20/pancm124/" rel="next" title="Nginx Linux和Windows安装教程">
                <i class="fa fa-chevron-left"></i> Nginx Linux和Windows安装教程
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/12/24/pancm126/" rel="prev" title="ElasticSearch实战系列四:ElasticSearch理论知识介绍">
                ElasticSearch实战系列四:ElasticSearch理论知识介绍 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/xuwujing.png"
               alt="虚无境" />
          <p class="site-author-name" itemprop="name">虚无境</p>
           
              <p class="site-description motion-element" itemprop="description">The way of the future!</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives/">
                <span class="site-state-item-count">136</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">30</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">59</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/xuwujing" target="_blank" title="github">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  github
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://blog.csdn.net/qazwsxpcm?viewmode=list" target="_blank" title="csdn">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  csdn
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://home.cnblogs.com/u/xuwujing/" target="_blank" title="cnblogs">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  cnblogs
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.woainia.site/" title="woainia" target="_blank">woainia</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://cmsblogs.com/" title="chenssy" target="_blank">chenssy</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://italker.imisty.cn" title="xiaowu" target="_blank">xiaowu</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#负载均衡介绍"><span class="nav-number">2.</span> <span class="nav-text">负载均衡介绍</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#介绍"><span class="nav-number">2.1.</span> <span class="nav-text">介绍</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#负载均衡策略"><span class="nav-number">2.2.</span> <span class="nav-text">负载均衡策略</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Nginx-SpringBoot实现负载均衡"><span class="nav-number">3.</span> <span class="nav-text">Nginx+SpringBoot实现负载均衡</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#环境准备"><span class="nav-number">3.1.</span> <span class="nav-text">环境准备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Nginx-配置"><span class="nav-number">3.2.</span> <span class="nav-text">Nginx 配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#负载均衡测试"><span class="nav-number">3.3.</span> <span class="nav-text">负载均衡测试</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#其他"><span class="nav-number">4.</span> <span class="nav-text">其他</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#参考"><span class="nav-number">4.1.</span> <span class="nav-text">参考</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#相关文章"><span class="nav-number">4.2.</span> <span class="nav-text">相关文章</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#音乐推荐"><span class="nav-number">4.3.</span> <span class="nav-text">音乐推荐</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">虚无境</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

  <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
 | 
本站总访问量<span id="busuanzi_value_site_pv"></span>次
 | 
本站访客数<span id="busuanzi_value_site_uv"></span>人次
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=857896&auto=0&height=66"></iframe>



        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
